package com.gzx.plugin.tjzy.modular.file.service;

import com.amazonaws.services.s3.model.Bucket;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.List;

/**
 * @author zjt
 * @description
 * @since 2024/10/18 15:11
 */
public interface FileService {

    /**
     * 创建存储桶
     */
    void createBucket(String bucketName);

    /**
     * 获取桶列表
     *
     * @return
     */
    List<Bucket> getBucketList();

    /**
     * 上传文件
     *
     * @param file
     * @return
     * @throws IOException
     */
    String upload(MultipartFile file) throws IOException;

    /**
     * 文件上传
     *
     * @param bucketName    上传的桶的名称
     * @param multipartFile 文件
     * @param withTimestamp 是否带时间戳
     * @return
     */
    String upload(String bucketName, MultipartFile multipartFile, boolean withTimestamp) throws IOException;

    /**
     * 下载
     *
     * @param fileName
     * @throws IOException
     */
    void download(String fileName, HttpServletResponse response);

    /**
     * 下载
     *
     * @param fileName
     * @throws IOException
     */
    void downloadWithBucket(String bucketName, String fileName, HttpServletResponse response) throws FileNotFoundException;

    File download(String bucketName, String fileName) throws IOException;

    /**
     * 上传文件，不带时间戳后缀
     *
     * @param file
     * @return
     * @throws IOException
     */
    public String uploadNoTimeSuffix(MultipartFile file) throws IOException;

    /**
     * 删除文件
     *
     * @param name
     */
    void deleteFile(String name);

    /**
     * 删除文件
     *
     * @param bucketName
     * @param fileName
     */
    void delete(String bucketName, String fileName);
}
